package com.xuecheng.media.feignclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author itcast
 */
@Slf4j
@Component
public class ContentServiceClientFallbackFactory implements FallbackFactory<ContentServiceClient> {
    @Override
    public ContentServiceClient create(Throwable throwable) {
        return new ContentServiceClient() {
            @Override
            public Integer countByMediaId(String mediaId) {
                log.error("根据媒资id查询教学计划数量发生熔断，媒资id：{}，异常信息：{}", mediaId, throwable.toString(), throwable);
                return 1;
            }
        };
    }
}
